package com.heihei.authority.core.authentication;

import com.heihei.authority.core.properties.FeiSecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;


public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {

	@Autowired
	protected AuthenticationSuccessHandler feiAuthenticationSuccessHandler;
	
	@Autowired
	protected AuthenticationFailureHandler feiAuthenticationFailureHandler;
	
	protected void applyPasswordAuthenticationConfig(HttpSecurity http) throws Exception {
		http.formLogin()
			.loginPage(FeiSecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
			.loginProcessingUrl(FeiSecurityConstants.DEFAULT_LOGIN_PROCESSING_URL_FORM)
			.successHandler(feiAuthenticationSuccessHandler)
			.failureHandler(feiAuthenticationFailureHandler);
	}
	
}
